home *** CD-ROM | disk | FTP | other *** search
- import java.util.Random;
-
- public class EnemyObject {
- final int STAND = 0;
- final int WALK = 1;
- final int JUMP = 2;
- final int CROUCH = 3;
- final int ATTACK = 4;
- final int CROUCH_ATTACK = 5;
- final int HIT = 6;
- final int CROUCH_HIT = 7;
- FightCanvas parent;
- static Random rand = new Random();
- // $FF: renamed from: x int
- int field_0;
- // $FF: renamed from: y int
- int field_1;
- int state;
- int interval;
- int walking;
- int stop_walking;
- int walk_state;
- int stand_state;
- boolean crouching;
- boolean jump_up;
- int jump_attack_state;
- int jump_pos;
- int attack_dur;
- int attack_type;
- boolean blocking;
- boolean attacking = false;
- public byte energy = 25;
- public byte power = 3;
- public byte speed = 3;
- public byte jump = 10;
- int hit_dur;
- boolean hit_jump;
-
- public EnemyObject(FightCanvas var1) {
- this.parent = var1;
- this.init();
- }
-
- public void setSkills(byte[] var1) {
- this.energy = var1[0];
- this.power = var1[1];
- this.speed = var1[2];
- this.jump = var1[3];
- }
-
- public void cpuMove() {
- if (this.interval % 3 == 0) {
- int var1 = rand.nextInt() % 9;
- if (var1 >= 0) {
- switch (var1) {
- case 0:
- this.stepLeft();
- break;
- case 1:
- this.stepRight();
- break;
- case 2:
- this.jump();
- break;
- case 3:
- this.crouchStart();
- break;
- case 4:
- this.attack(0);
- break;
- case 5:
- this.attack(2);
- break;
- case 6:
- this.attack(1);
- break;
- case 7:
- this.attack(3);
- break;
- case 8:
- this.block();
- }
-
- }
- }
- }
-
- public void init() {
- this.state = 0;
- this.field_0 = 0;
- this.field_1 = 48;
- this.walk_state = 0;
- this.stand_state = 0;
- this.stop_walking = 0;
- this.jump_pos = 0;
- this.blocking = false;
- this.attacking = false;
- }
-
- public boolean isHit() {
- return this.state == 6 || this.state == 7;
- }
-
- public void checkRange() {
- if (this.field_0 > this.parent.playerSpr.getXPosition() - 5) {
- this.field_0 = this.parent.playerSpr.getXPosition() - 5;
- }
-
- if (this.field_0 < 0) {
- this.field_0 = 0;
- }
-
- if (this.field_0 > 65) {
- this.field_0 = 65;
- }
-
- }
-
- static int abs(int var0) {
- return var0 < 0 ? -var0 : var0;
- }
-
- public void attack(int var1) {
- switch (this.state) {
- case 0:
- case 1:
- this.state = 4;
- this.attack_dur = 2;
- switch (var1) {
- case 0:
- this.attack_type = 1;
- return;
- case 1:
- this.attack_type = 0;
- return;
- case 2:
- this.attack_type = 1;
- return;
- case 3:
- this.attack_type = 0;
- return;
- default:
- return;
- }
- case 2:
- if (this.walking != 0) {
- this.jump_attack_state = 1;
- } else {
- this.jump_attack_state = 2;
- }
- break;
- case 3:
- this.state = 5;
- this.attack_dur = 3;
- switch (var1) {
- case 0:
- this.attack_type = 0;
- break;
- case 1:
- this.attack_type = 1;
- break;
- case 2:
- this.attack_type = 1;
- break;
- case 3:
- this.attack_type = 0;
- }
- }
-
- }
-
- public void block() {
- switch (this.state) {
- case 0:
- case 1:
- this.attack_dur = 4;
- this.state = 4;
- this.attack_type = 2;
- case 2:
- default:
- break;
- case 3:
- this.attack_dur = 4;
- this.state = 5;
- this.attack_type = 2;
- }
-
- }
-
- public void hit() {
- switch (this.state) {
- case 0:
- case 1:
- this.state = 6;
- this.hit_dur = 4;
- break;
- case 2:
- this.hit_jump = true;
- break;
- case 3:
- this.state = 7;
- this.hit_dur = 5;
- }
-
- }
-
- public void crouchStart() {
- if (this.state != 2) {
- if (this.crouching) {
- this.state = 1;
- this.crouching = false;
- } else {
- this.state = 3;
- this.crouching = true;
- }
-
- }
- }
-
- public void stepLeft() {
- this.walking = -1;
- if (this.state == 2) {
- this.walking = -3;
- }
-
- this.walk_state = 1;
- --this.stop_walking;
- }
-
- public void stepRight() {
- this.walking = 1;
- if (this.state == 2) {
- this.walking = 3;
- }
-
- this.walk_state = 0;
- --this.stop_walking;
- }
-
- public void walkReset() {
- if (this.crouching) {
- this.state = 3;
- } else if (this.walking == 0) {
- this.state = 0;
- } else {
- this.state = 1;
- }
-
- this.hit_jump = false;
- this.stop_walking = 0;
- }
-
- public void jump() {
- switch (this.state) {
- case 0:
- case 1:
- case 3:
- this.jump_up = true;
- this.jump_attack_state = 0;
- this.state = 2;
- this.crouching = false;
- case 2:
- default:
- }
- }
-
- public void run() {
- ++this.interval;
- switch (this.state) {
- case 0:
- case 1:
- if (this.walking != 0) {
- this.state = 1;
- ++this.walk_state;
- if (this.stop_walking >= 0 && (this.walk_state + 1) % 2 == 0) {
- this.walking = 0;
- }
-
- this.field_0 += this.walking * this.speed;
- this.checkRange();
- } else {
- this.state = 0;
- if (this.interval % 2 == 0) {
- ++this.stand_state;
- }
- }
- break;
- case 2:
- if (this.hit_jump) {
- this.field_0 += -this.speed;
- }
-
- if (this.jump_up) {
- this.jump_pos += this.jump;
- if (this.jump_pos >= 2 * this.jump) {
- this.jump_up = false;
- ++this.jump_pos;
- }
- } else {
- this.jump_pos -= this.jump;
- if (this.jump_pos <= 0) {
- this.jump_pos = 0;
- this.walking = 0;
- this.walkReset();
- }
- }
-
- this.field_0 += this.walking * this.speed;
- case 3:
- default:
- break;
- case 4:
- --this.attack_dur;
- if (this.attack_dur == 0) {
- this.walkReset();
- }
- break;
- case 5:
- --this.attack_dur;
- if (this.attack_dur == 0) {
- this.walkReset();
- }
- break;
- case 6:
- this.field_0 -= this.speed;
- --this.hit_dur;
- if (this.hit_dur == 0) {
- this.walkReset();
- }
- break;
- case 7:
- --this.hit_dur;
- this.field_0 -= this.speed;
- if (this.hit_dur == 0) {
- this.walkReset();
- }
- }
-
- this.checkRange();
- if (this.state != 4 && this.state != 5) {
- this.attacking = false;
- } else {
- this.attacking = true;
- }
-
- if ((this.state != 5 || this.attack_type != 2) && (this.state != 4 || this.attack_type != 2)) {
- this.blocking = false;
- } else {
- this.blocking = true;
- this.attacking = false;
- }
-
- this.setPlayerFrame();
- }
-
- public void setPlayerFrame() {
- int var1;
- var1 = 0;
- label29:
- switch (this.state) {
- case 0:
- var1 = this.stand_state % 2;
- break;
- case 1:
- var1 = this.walk_state % 2 + 2;
- break;
- case 2:
- if (this.hit_jump) {
- var1 = 7;
- } else if (this.jump_up) {
- switch (this.jump_attack_state) {
- case 2:
- var1 = 14;
- break label29;
- default:
- var1 = 12;
- }
- } else {
- switch (this.jump_attack_state) {
- case 0:
- var1 = 13;
- break label29;
- case 1:
- var1 = 14;
- break label29;
- case 2:
- var1 = 15;
- }
- }
- break;
- case 3:
- var1 = 8;
- break;
- case 4:
- var1 = this.attack_type + 4;
- break;
- case 5:
- var1 = this.attack_type + 9;
- break;
- case 6:
- var1 = 7;
- break;
- case 7:
- var1 = 12;
- }
-
- this.parent.enemySpr.setFrame(var1);
- }
- }
-